<?xml version="1.0" encoding="UTF-8"?>
<ui:composition
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
	template="/WEB-INF/templates/default.xhtml"
	xmlns:pe="http://primefaces.org/ui"
>

	<f:metadata>
		<f:viewParam
			name="bulletinId"
			value="#{bulletinHome3.id}"
		></f:viewParam>
		<f:event
			listener="#{bulletinHome3.initConversation()}"
			type="preRenderView"
		></f:event>
	   	<f:viewParam name="moduleName" value="取消成交结果"></f:viewParam>
	</f:metadata>
	<ui:define name="head">
		<style type="text/css">
			.removeButton {
				float: right;
				margin-right: 20px;
			}
			
			.limitUnit {
				margin-top: 5px;
			}
			h2{
   				text-align:center
   			}
   			.rowStyle{
	   			text-align: center;
	   			font-size:16px
   			}
		</style>
	</ui:define>
	<ui:define name="content">

		<h:form id="editForm">
			<p:panel
				id="panel"
				header="公告基本信息"
				style="margin-bottom:10px;"
			>
				<p:messages id="messages" closable="true">
		       		<p:autoUpdate />
		       	</p:messages>
				<ui:include src="../template/include/bulletinInfo.xhtml" />
			</p:panel>
			<p:panel
				id="photos"
				header="交易申请表"
				style="margin-bottom:10px;"
						>
				<div id="imgsPreview" >
					<p:repeat
						var="_photo"
						value="#{bulletinHome3.instance.photos}"
					>
						<img  data-original="#{attachmentUtils.getFullPath(_photo)}" src="#{attachmentUtils.getFullPath(_photo)}"  width="240"/>
					</p:repeat>
				</div>	
			</p:panel>
			<p:panel header="相关附件">	
				 	<ui:include src="/WEB-INF/templates/include/bulletinAttachments.xhtml" />
			</p:panel>
			<p:panel id="bulletinReqs" header="公告要求">
				<h:panelGrid columns="2" cellpadding="5"
					columnClasses="column1,column2">
					<p:outputLabel for="rootQualificationGroup" value="匹配规则" />
					<h:outputText id="rootQualificationGroup"
						style="font-size:16px;color:red"
						value="#{bulletinHome3.instance.qualificationGroup.relation.typeName}" />
				</h:panelGrid>
				<p:panel id="agentServiceReqs" header="服务事项要求"
					rendered="#{bulletinHome3.instance.qualificationGroup.getAgentServiceGroups().size() > 0}"
					style="margin-bottom:10px;">
					<p:repeat var="_serviceGroup"
						value="#{bulletinHome3.instance.qualificationGroup.getAgentServiceGroups()}"
						varStatus="_groupStatus">
						<p:panelGrid cellpadding="5"
							style=" margin-bottom: 10px;width:100%">
							<p:row style="width:100%">
								<p:column>
									<h2>服务事项要求组#{_groupStatus.index +
										1}（#{_serviceGroup.relation.typeName}组）</h2>
								</p:column>
							</p:row>

							<p:row>
								<p:column>
									<p:panelGrid cellpadding="5" style="width:100%">
										<p:row styleClass="rowStyle">
											<p:column>服务事项名称</p:column>
											<p:column>对应资质大类</p:column>
										</p:row>

										<p:repeat var="_service"
											value="#{_serviceGroup.agentServices}">
											<p:row>
												<p:column>
													<h:outputText value="#{_service.name}" />
												</p:column>
												<p:column>
													<h:outputText value="#{_service.qualificationClass.name}" />
												</p:column>
											</p:row>
										</p:repeat>
									</p:panelGrid>
								</p:column>
							</p:row>
						</p:panelGrid>
					</p:repeat>
				</p:panel>

				<p:panel id="reqs" header="资质要求"
					rendered="#{bulletinHome3.instance.qualificationGroup.getQualificationGroups().size () > 0}"
					style="margin-bottom:10px;">
					<h:outputText
						value="#{bulletinHome3.instance.qualificationGroup.getQualificationGroupDetail()}" />
				</p:panel>

			</p:panel>
			
			<p:panel
				id="selecteSupplier"
				header="已选取的中介"
				rendered="#{not empty bulletinHome3.instance.successTrade}"
				style="margin-bottom:10px;"
			>
				<p:outputLabel
					for="supplier"
					value="中介名称："
					style="margin:5px 10px"
				></p:outputLabel>
				<h:outputText
					id="supplier"
					value="#{bulletinHome3.instance.successTrade.supplier.cnname}"
				/>
			</p:panel>
			<p:commandButton
				oncomplete="PF('rejectDialog').show();"
				value="取消"
				immediate="true"
			></p:commandButton>
			<p:commandButton
				action="#{bulletinHome3.cancel()}"
				value="取消"
				immediate="true"
			></p:commandButton>
		</h:form>

		<p:dialog
			id="rejectDialog"
			widgetVar="rejectDialog"
		>
			<f:facet name="header">
				取消原因
			</f:facet>
			<h:form>
				<p:panelGrid columns="2">
					<p:outputLabel
						for="reason"
						value="取消原因"
					></p:outputLabel>
					<p:inputTextarea
						id="reason"
						value="#{bulletinHome3.instance.cancelReason}"
						required="true"
						cols="80"
						rows="5"
					></p:inputTextarea>
				</p:panelGrid>

				<p:commandButton
					action="#{bulletinHome3.auditCancelSuccessBulletin()}"
					value="确认"
					ajax="false"
				/>
				<p:commandButton
					oncomplete="PF('rejectDialog').hide();"
					value="取消"
					immediate="true"
				></p:commandButton>
			</h:form>
		</p:dialog>
		

	</ui:define>
</ui:composition>
